//
//  FWAuthParam.m
//  FWShare
//
//  Created by 范文青 on 14-6-14.
//  Copyright (c) 2014年 fwq. All rights reserved.
//

#import "FWAuthParam.h"
#import <objc/runtime.h>
@implementation FWAuthParam
- (NSArray *)allProperties
{
    NSMutableArray  *propertyKeys = [NSMutableArray array];
    unsigned int outCount = 0;
    objc_property_t *properties = class_copyPropertyList([self class], &outCount);
    for (int i = 0; i < outCount; i++)
    {
        objc_property_t property = properties[i];
        NSString *key=[[NSString alloc] initWithCString:property_getName(property)
                                               encoding:NSUTF8StringEncoding];
        [propertyKeys addObject:key];
    }
    free(properties);
    return propertyKeys;
}

-(NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary  *params = [NSMutableDictionary dictionary];
    NSArray  *propertyList = [self allProperties];
    [propertyList enumerateObjectsUsingBlock:^(id key, NSUInteger idx, BOOL *stop){
        id value=[self valueForKey:key];
        if (value != nil)
        {
            [params setObject:value forKey:key];
        }
    }];
    return [NSDictionary dictionaryWithDictionary:params];
}
@end
